package com.zzxy.spring21.test;

import com.zzxy.spring21.controller.StudentController;
import com.zzxy.spring21.factory.MyBeanFactory;
import com.zzxy.spring21.factory.MyBeanFactoryCglib;
import com.zzxy.spring21.service.IStudentService;
import com.zzxy.spring21.service.impl.AccountServceImpl;
import com.zzxy.spring21.service.impl.StudentServiceImpl;
import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;

public class Tset {


    public static void main(String[] args) throws Exception {
//        //ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans1.xml");
//
////        StudentController studentController = (StudentController) context.getBean("studentController");
////        studentController.addStudent("zhangsan","123");
//        //StudentController controller = context.getBean(StudentController.class);
//        //controller.addStudent("zhangsan","123");
////        IStudentService studentServiceProxy = MyBeanFactoryCglib.createStudentServiceProxy();
////        studentServiceProxy.deleteStudent(1);
////        StudentServiceImpl studentService = new StudentServiceImpl();
//        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans6.xml");
//        StudentServiceImpl stuServiceProxy = (StudentServiceImpl) context.getBean("stuService");
//        stuServiceProxy.updateStudent(1);
////        StudentServiceImpl studentService = context.getBean(StudentServiceImpl.class);
////        studentService.updateStudent(1);
//        BasicDataSource dataSource = new BasicDataSource();
//        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
//        dataSource.setUrl("jdbc:mysql:///spring21?serverTimezone=UTC");
//        dataSource.setUsername("root");
//        dataSource.setPassword("123456");
//        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
//        jdbcTemplate.update("insert into t_user values (null,?,?)","zhangsan","123");
//        jdbcTemplate.update("update t_user set username = ? where id=?","lisi",3);
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("beans8.xml");
        AccountServceImpl accountService = (AccountServceImpl) context.getBean("accountService");
        accountService.transer("jack","rose",1000);
    }
}